<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Home extends CI_Controller {
	//用户登录的标志
	private $onFlag = array();
	function __construct()
	{
		parent::__construct();
		$this->load->library('session');
		$data['site_title'] = $this->config->item('site_title');
		$this->load->vars($data);
		$userinfo = $this->session->userdata('lz_chinese_user');
		//$userinfo['lz_u'] = 1;
		if(!empty($userinfo['lz_u'])){
			$this->onFlag = $userinfo;
		}
	}

	//logon logoff
	public function logon(){
		if(count($this->onFlag)){
			header('location:/index.php/admin');
			exit;
		}
		$this->load->model('admin/logon');
		if(!empty($_POST['logon'])){
			$username = isset($_POST['username'])?$_POST['username']:'';
			$passwd = isset($_POST['passwd'])?$_POST['passwd']:'';
			$validate = isset($_POST['validate'])?$_POST['validate']:'';
			
			$this->logon->logon($username, $passwd, $validate);
		}else{
			$this->logon->logon();
		}
		$this->load->view('admin/logon_page');
	}
	public function logoff(){
		$this->load->model('admin/logon');
		$this->logon->logoff();
	}
	private function isLogon(){
		if(empty($this->onFlag['lz_u'])){
			//header('location:/index.php/admin/home/logon');
			echo '<script>parent.location.href="/index.php/admin/home/logon"</script>';
			exit;
		}
	}
	//上传图片
	public function uploadpic()
	{
		$this->isLogon();
		$this->load->model('admin/dashboard');
		$this->dashboard->uploadPic();
		$this->load->view('admin/uploadpic_page');
	}
 	//首页
	public function index()
	{
		$this->isLogon(); 
		$this->load->model('admin/dashboard');
		$this->load->view('admin/dashboard_page');
	}
	//菜单栏
	public function menuside()
	{  
		$this->load->view('admin/menuside_page');
	}
	//更新缓存ajax
	public function trcJS(){
		$this->isLogon();
		$this->load->model('admin/dashboard');
		$this->dashboard->trcJS();
		$this->load->view('admin/trcjs_page');
	}
	//更新缓存ajax
	public function updateCache(){
		$this->isLogon();
		$this->load->model('admin/dashboard');
		$this->dashboard->updateCache($_POST);
	}
	//导航栏
	public function naviTits()
	{
		$this->isLogon(); 
		$this->load->model('admin/dashboard');
		$this->dashboard->m_naviTits($_POST);
		$this->load->view('admin/navitits_page');
	}
	//友情链接
	public function friendLink()
	{
		$this->isLogon(); 
		$this->load->model('admin/dashboard');
		$this->dashboard->m_friendLink();
		$this->load->view('admin/friendlink_page');
	}
	//公司简介
	public function about()
	{
		$this->isLogon(); 
		$this->load->model('admin/dashboard');
		$this->dashboard->m_about();
		$this->load->view('admin/about_page');
	}
	//每日一句
	public function dailyone()
	{
		$this->isLogon(); 
		$this->load->model('admin/dashboard');
		$this->dashboard->m_dailyone();
		$this->load->view('admin/dailyone_page');
	}
	//每日一句列表
	public function dailyonelist()
	{
		$this->isLogon();
		$this->load->model('admin/dashboard');
		$this->dashboard->m_dailyonelist();
		$this->load->view('admin/dailyonelist_page');
	}
	//版权设置
	public function copyright()
	{
		$this->isLogon(); 
		$this->load->model('admin/dashboard');
		$this->dashboard->m_copyright();
		$this->load->view('admin/copyright_page');
	}
	//汉语知识
	public function knowledge()
	{
		$this->isLogon(); 
		$this->load->model('admin/dashboard');
		$this->dashboard->m_knowledge();
		$this->load->view('admin/knowledge_page');
	}
	//课程
	public function course()
	{
		$this->isLogon(); 
		$this->load->model('admin/dashboard');
		$this->dashboard->m_course();
		$this->load->view('admin/course_page');
	}
	//联系方式
	public function contact()
	{
		$this->isLogon(); 
		$this->load->model('admin/dashboard');
		$this->dashboard->m_contact();
		$this->load->view('admin/contact_page');
	}
	//首页焦点
	public function indexFocus()
	{
		$this->isLogon(); 
		$this->load->model('admin/dashboard');
		$this->dashboard->m_indexFocus();
		$this->load->view('admin/indexfocus_page');
	}
	//首页middle
	public function indexMiddle()
	{
		$this->isLogon(); 
		$this->load->model('admin/dashboard');
		$this->dashboard->m_indexMiddle();
		$this->load->view('admin/indexmiddle_page');
	}
}
